package com.enation.app.javashop.api.client;


import com.enation.app.javashop.model.payment.dos.PaymentMethodDO;
import com.enation.app.javashop.model.payment.dto.PayParam;
import com.enation.app.javashop.service.payment.PaymentManager;
import com.enation.app.javashop.service.payment.PaymentMethodManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

/**
 * 支付中心client实现
 *
 * @author fk
 * @version v7.0
 * @date 20/3/9 下午3:51
 * @since v7.2.1
 */
@RestController
@RequestMapping("/client/payment")
@Validated
@ApiIgnore
public class PaymentClientController {

    @Autowired
    private PaymentManager paymentManager;

    @Autowired
    private PaymentMethodManager paymentMethodManager;

    @RequestMapping(value = "/pay", method = RequestMethod.POST)
    public Map pay(@RequestBody PayParam param) {

        return paymentManager.pay(param);
    }

    @RequestMapping(value = "/bill", method = RequestMethod.GET)
    public String queryBill(@RequestParam("sub_sn") String subSn, @RequestParam("service_type") String serviceType) {

        return paymentManager.queryResult(subSn, serviceType);
    }


    @RequestMapping(value = "/{plugin_id}",method = RequestMethod.GET)
    public PaymentMethodDO getByPluginId(@PathVariable("plugin_id") String pluginId){

        return paymentMethodManager.getByPluginId(pluginId);
    }
}
